/**
 * Created by pankaj on 25/10/14.
 */
define(['jquery', 'module/form/validate'], function($, validateEmail){

    var form = function(){
        var validate = function(){
            var userName = $(".js_login_form .js_email").val();
            if (!validateEmail.validateEmail(userName)) {
                $(".js_login_form .js_emailError").css('display', 'block');
                return false;
            } else {
                $(".js_login_form .js_emailError").css('display', 'none');
            }

            var password = $(".js_login_form .js_pass").val();

            if (password.length == 0) {
                $(".js_login_form #passwordError").css('display', 'block');
                return false;
            } else {
                $(".js_login_form #passwordError").css('display', 'none');
            }
            return true;
        };
        // bind click event.
        $(".js_login_form .js_submit").click(function(event) {
            if(validate()){
                $(".js_login_form").submit();
            }
        });
    };
    return form;
});